package ithema.contriller;

import ithema.pojo.Address;
import ithema.pojo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ResponseController {

//    @RequestMapping("/hello1")
//    public String hello(){
//        System.out.println("Hello World~");
//        return "Hello World~";
//    }
//
//    @RequestMapping("/address")
//    public Address getAddress(){
//        Address address = new Address();
//        address.setCity("北京");
//        address.setProvince("北京");
//        return address;
//    }
//
//    @RequestMapping("/addressList")
//    public List<Address> getAddressList(){
//        List<Address> addressList = new ArrayList<>();
//
//        Address address1 = new Address();
//        address1.setCity("北京");
//        address1.setProvince("北京");
//        Address address2 = new Address();
//        address2.setCity("上海");
//        address2.setProvince("上海");
//
//        addressList.add(address1);
//        addressList.add(address2);
//        return addressList;
//    }



    @RequestMapping("/hello1")
    public Result hello(){
        System.out.println("Hello World~");
        //return new Result(1,"success","Hello World~");
        return Result.success("Hello World~");
    }

    @RequestMapping("/address")
    public Result getAddress(){
        Address address = new Address();
        address.setCity("北京");
        address.setProvince("北京");
        return Result.success(address);
    }

    @RequestMapping("/addressList")
    public Result getAddressList(){
        List<Address> addressList = new ArrayList<>();

        Address address1 = new Address();
        address1.setCity("北京");
        address1.setProvince("北京");
        Address address2 = new Address();
        address2.setCity("上海");
        address2.setProvince("上海");

        addressList.add(address1);
        addressList.add(address2);
        return Result.success(addressList);
    }
}
